package com.example.framework;

import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

public class HelperWithWebDriverBase {

	protected ApplicationManager manager;
	private WebDriver driver;	
	
	public HelperWithWebDriverBase (ApplicationManager manager) {
		this.manager = manager;
		driver = manager.getWebDriverHelper().getDriver();
	}
	//public void submitElementCreation() {
			void submitElementCreation() {
				driver.findElement(By.name("submit")).click();
			}

			//public void type(By locator, String name) {
			void type(By locator, String name) {
				driver.findElement(locator).clear();
				driver.findElement(locator).sendKeys(name);
			}

			/*private boolean isElementPresent(By by) {
				try {
					driver.findElement(by);
					return true;
				} catch (NoSuchElementException e) {
					return false;
				}
			}*/

			void fillDropDownList(By locator, String name) {
				new Select(driver.findElement(locator)).selectByVisibleText(name);
			}
			
			protected WebElement findElement(By linkText) {
				return driver.findElement(linkText);
			}
			
			protected List<WebElement> findElements(By linkText) {
				return driver.findElements(linkText);
			}
			
			protected void openUrl(String string) {
				driver.get(string);
			}
			
			protected void click(By linkText) {
				findElement(linkText).click();
			}
			
}
